<template>
  <div>
    <el-dialog
      title="添加/修改图书"
      :visible.sync="dialogFormVisible"
      @close="clear"
    >
      <el-form v-model="form" style="text-align: left" ref="dataForm">

        <el-form-item label="资源标题" :label-width="formLabelWidth" prop="title">
          <el-input
            v-model="form.title"
            autocomplete="off"
            placeholder=""
          ></el-input>
        </el-form-item>
        <el-form-item label="资源链接" :label-width="formLabelWidth" prop="author">
          <el-input v-model="form.ddesc" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="提取码" :label-width="formLabelWidth" prop="press">
          <el-input v-model="form.dcode" autocomplete="off"></el-input>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="onSubmit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "EditForm",
  components:{},
  data() {
    return {
      dialogFormVisible: false,
      form: {
        title: "",
        ddesc: "",
        dcode: "",
      },
      formLabelWidth: "120px"
    };
  },
  methods: {
    clear() {
      this.form = {
        title: "",
        ddesc: "",
        dcode: "",
      };
    },
    onSubmit() {
      this.$axios
        .post("/resource/add", {
          title: this.form.title,
          ddesc: this.form.ddesc,
          dcode: this.form.dcode,
        })
        .then(resp => {
          if (resp && resp.status === 200) {
            this.dialogFormVisible = false;
            this.$emit("onSubmit");
          }
        });
    },
  }
};
</script>

<style scoped>
.el-icon-circle-plus-outline {
  margin: 50px 0 0 20px;
  font-size: 100px;
  float: left;
  cursor: pointer;
}
</style>
